cmake_minimum_required(VERSION 3.10)
project(desktopdemo VERSION 0.1.1)

# 添加源文件
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)

# 创建可执行文件
add_executable(${PROJECT_NAME} ${SOURCES})

# 链接 tslib 库
target_link_libraries(${PROJECT_NAME} PRIVATE tslib)

# 链接 LVGL 库
target_link_libraries(${PROJECT_NAME} PRIVATE lvgl)

# 链接 lv_drivers 库
target_link_libraries(${PROJECT_NAME} PRIVATE lv_drivers)

# 链接 sqlite3 库
target_link_libraries(${PROJECT_NAME} PRIVATE
    sqlite3
    pthread
    m
)

# 包含头文件目录
target_include_directories(${PROJECT_NAME} PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/src
    ${CMAKE_CURRENT_SOURCE_DIR}/src/com
    ${CMAKE_CURRENT_SOURCE_DIR}/src/pages
    ${CMAKE_SOURCE_DIR}/lvgl
    ${CMAKE_SOURCE_DIR}/lv_drivers
)

# 设置编译选项
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra)

# 启用LVGL日志功能
target_compile_definitions(${PROJECT_NAME} PRIVATE LV_USE_LOG=1)

# 设置RPATH相关属性
set_target_properties(${PROJECT_NAME} PROPERTIES
    INSTALL_RPATH "$ORIGIN/../lib"
    BUILD_WITH_INSTALL_RPATH TRUE
    SKIP_BUILD_RPATH FALSE
)

# 设置编译输出目录
set_target_properties(${PROJECT_NAME} PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)

# 安装可执行文件
install(TARGETS ${PROJECT_NAME}
	RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")

# 安装资源
#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/resource/ DESTINATION resource)